package com.ms.pda.adapter

import androidx.databinding.ViewDataBinding
import com.blankj.utilcode.util.CollectionUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.ms.pda.BR
import com.ms.pda.R
import com.ms.pda.model.KeyMap
import com.ms.pda.model.table.StorageOutDO
import com.ms.pda.model.vo.StorageOutVo

class StorageOutRVAdapter(layoutResId: Int, data: MutableList<StorageOutVo>?) :
    BaseQuickAdapter<StorageOutVo, BaseDataBindingHolder<ViewDataBinding>>(layoutResId, data) {

    constructor() : this(
        R.layout.item_storage_out,
        CollectionUtils.newArrayList()
    )

    override fun convert(holder: BaseDataBindingHolder<ViewDataBinding>, item: StorageOutVo) {
        if ((holder.layoutPosition + 1) % 2 == 0) {
            holder.setBackgroundColor(
                R.id.storage_out_item,
                context.getColor(R.color.line_color_50p)
            )
        } else {
            holder.setBackgroundColor(
                R.id.storage_out_item,
                context.getColor(R.color.transparent)
            )
        }
        holder.dataBinding?.setVariable(BR.data, item)
        holder.dataBinding?.executePendingBindings()
    }
}